package com.jswlw.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@AllArgsConstructor(staticName = "of")
public class BaseException extends RuntimeException {

    @Getter
    private Integer code;
    @Getter
    private String msg;

    public static BaseException of(ResponseStatus status) {
        return of(status.getCode(), status.getMsg());
    }

    public static void sneakyThrows(ResponseStatus status) {
        throw of(status.getCode(), status.getMsg());
    }

    public static void sneakyThrows(Integer code, String msg) {
        throw of(code, msg);
    }

    @Override
    public String getMessage() {
        return this.msg;
    }
}